/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#include "StdAfx.h"
#include "LUA_GUI_Manager.h"
#include "lunar.h"
#include "LUA_Component.h"
#include "LUA_Dialog.h"
#include "LUA_Label.h"
#include "LUA_Panel.h"
#include "LUA_Button.h"

LUA_GUI_Manager::LUA_GUI_Manager(void)
{
}

LUA_GUI_Manager::~LUA_GUI_Manager(void)
{
}


/** Get a component */
int LUA_GUI_Manager::GetComponent( lua_State *L )
{
        // retrieve the name from lua
    std::string name = luaL_checkstring( L, 1 );
    gui::Component* com = gui::GUI_Manager::GetInstance()->GetParentComponent( name );
    if ( com )
    {
        // TODO
        //Lunar<LUA_Component>::push( L, static_cast<LUA_Component*>(com), true );
        //return 1;
    }
    return 0;
}
/** Add component */
int LUA_GUI_Manager::AddComponent( lua_State *L )
{
    return 0;
}
/** Remove component */
int LUA_GUI_Manager::RemoveComponent( lua_State *L )
{
    return 0;
}


// -- Bind to LUA
#define method(name) {#name, LUA_GUI_Manager::name}

const luaL_reg LUA_GUI_Manager::methods[] = {
        method(GetComponent),
        method(AddComponent),
        method(RemoveComponent),
        //method(LoadDialog),
        {NULL, NULL}
};

// - Bind to lua
int luaopen_LUA_GUI_Manager(lua_State *L) {
    luaL_openlib(L, "GUI_Manager", LUA_GUI_Manager::methods, 0);
    Lunar<LUA_Component>::Register( L );
    Lunar<LUA_Dialog>::Register( L );
    Lunar<LUA_Label>::Register( L );
    Lunar<LUA_Panel>::Register( L );
    Lunar<LUA_Button>::Register( L );
 	return 0;
}